package com.java.service.Impl;

import com.java.dao.AdminDao;
import com.java.dao.Impl.AdminDaoImpl;
import com.java.entity.Admins;
import com.java.entity.Orders;
import com.java.entity.Users;
import com.java.service.AdminService;

import java.sql.SQLException;
import java.util.List;

public class AdminServiceImpl implements AdminService {
    AdminDao dao = new AdminDaoImpl();
    @Override
    public Admins selectAdminByUserNameAndPassword(String userName, String password) throws SQLException {
        return dao.selectAdminByUserNameAndPassword(userName,password);
    }

    @Override
    public List<Orders> selectAllOrder() throws SQLException {
        return dao.selectAllOrders();
    }

    @Override
    public Orders selectOrdersByBookId(String bookId) throws SQLException {
        return dao.selectOrdersByBookId(bookId);
    }

    @Override
    public boolean UpdateOrderById(Orders orders) throws SQLException {
        return dao.updateOrderById(orders);
    }

    @Override
    public List<Users> selectAllUsers() throws SQLException {
        return dao.selectAllUsers();
    }

    @Override
    public Users selectUserById(String id) throws SQLException {
        return dao.selectUserById(id);
    }

    @Override
    public boolean updateUserById(Users users) throws SQLException {
        return dao.updateUserById(users);
    }
    @Override
    public List<Admins> selectAllAdmins() throws SQLException {
        return dao.selectAllAdmins();
    }

    @Override
    public Admins checkAdminById(String adminId) throws SQLException {
        return dao.checkAdminById(adminId);
    }

    @Override
    public boolean updateAdminById(Admins admins) throws SQLException {
        return dao.updateAdminById(admins);
    }

    @Override
    public boolean addAdmin(String id,String username, String password) throws SQLException {
        int i=dao.addAdmin(id,username,password);
        if(i>0){
            return  true;
        }
        return false;
    }
}
